<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="utf-8">
    <meta name="author" content="Yb">
    <title>练习</title>
    <style>
        
    </style>
</head>
<body>
    
</body>
</html>
<script>

    function People(name,age,isMale,birthdate,eat,sleep){
        this.name = name;
        this.age = age;
        this.isMale = isMale;
        this.birthdate = birthdate;
        this.eat = eat;
        this.sleep = sleep;
    }

    People.prototype.say = function(){
        console.log('我叫'+this.name+',今年'+this.age+'岁');
    }
    People.prototype.food = function(){
        console.log(this.name+'很喜欢吃'+this.eat);
    }
    People.prototype.hour = function(){
        console.log(this.name+'睡了'+this.sleep+'个小时');
    }
    People.prototype.game = function(){
        console.log(this.name+'喜欢玩'+this.play);
    }
    People.prototype.course = function(){
        console.log(this.name+'学习了'+this.study+'等，累死宝宝了...');
    }
    People.prototype.task = function(){
        console.log(this.name+'现在的工作是'+this.work+'，薪水是'+this.salary);
    }


    // baby对象
    var baby = new People('Tom',4,true,2013,'香蕉','16');
    baby.say();
    baby.food();
    baby.hour();
    console.log('-----------');

    // child对象
    People.prototype.play = '俄罗斯方块';
    var child = new People('Sim',12,true,2005,'苹果','10');
    child.say();
    child.food();
    child.hour();
    child.game();
    console.log('-----------');

    // student对象
    People.prototype.study = '语数外政史地理化生';
    var child = new People('小明',16,true,2000,'西红柿','9');
    child.say();
    child.food();
    child.hour();
    child.course();
    console.log('-----------');

    // worker对象
    People.prototype.salary = '18000';
    People.prototype.work = '前端开发工程师';
    var child = new People('大白',26,true,1991,'胡萝卜','8');
    child.say();
    child.food();
    child.hour();
    child.task();
    console.log('-----------');
</script>